package com.cn.qtms.entity;//类注释设置模板

import com.cn.qtms.base.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Name:TmSecGoods
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-12-26 10:50
 **/
@Entity
@Table(name = "tm_sec_goods")
@org.hibernate.annotations.Table(appliesTo = "tm_sec_goods",comment="秒杀商品表")
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class TmSecGoods extends BaseEntity {

    public static final String MON_DAY="Mon";
    public  static final String TUES_DAY="Tues";
    public static final String WED_DAY="Wed";
    public static final String THUR_DAY="Thur";
    public static final String FRI_DAY="Fri";
    public static final String SAT_DAY="Sat";
    public  static final String SUN_DAY="Sun";

    @Column(name="act_id",columnDefinition = "bigint(20) comment '活动id'" )
    @JsonSerialize(using = ToStringSerializer.class)
    private Long actId;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "act_id",insertable = false,updatable = false)
    private TmSecAct act;

    @Column(name="goods_id",columnDefinition = "bigint(20) comment '商品ID'" )
    @JsonSerialize(using = ToStringSerializer.class)
    private Long goodsId;

    @Column(name = "start_time", columnDefinition = "time COMMENT '开始时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "HH:mm:ss")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @Column(name = "end_time", columnDefinition = "time COMMENT '结束时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "HH:mm:ss")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    /**
     * 场次 1 10-12 2 12-14 3 18-20 4 20-22
     */
    @Column(name="act_type",columnDefinition = "int(10) comment '场次'" )
    private Integer actType;

    /**
     *周几 将周一到周日英文组成字符串，隔开
     */
    @Column(name = "week", columnDefinition = "varchar(255) COMMENT '周几'")
    private String  week;

    /**
     * 周几 前端用 将week字符串拆分作为数组
     */
    @Transient
    private List<String> weekDays;

    /**
     * 单次库存
     */
    @Column(name="each_count",columnDefinition = "int(10) COMMENT '单次库存'" )
    private  Integer eachCount;

    /**
     * 活动结束总消耗库存
     */
    @Column(name="total_count",columnDefinition = "int(10) COMMENT '活动结束总消耗库存'" )
    private Integer totalCount;

    /**
     * 剩余给后续秒杀活动库存
     */
    @Column(name="current_count",columnDefinition = "int(10) COMMENT '剩余总库存'" )
    private Integer currentsCount;
    /**
     * 是否单人限购
     */
    @Column(name = "is_limit", columnDefinition = "bit(1) default 0 COMMENT '是否单人限购'")
    private Boolean isLimit;
    /**
     * 单人限购数目
     */
    @Column(name="limit_no",columnDefinition = "int(10) COMMENT '单人限购次数'" )
    private Integer limitNo;

    @Column(name = "sec_price", columnDefinition = "decimal(9,2) COMMENT '秒杀价'")
    private BigDecimal secPrice;

    @Column(name = "status", columnDefinition = "varchar(10) COMMENT '状态 0:默认 1.已移除'")
    private String status;
}
